#include "mydialog.h"
#include "ui_mydialog.h"
#include <QPropertyAnimation>
#include <QxtGlobalShortcut>

MyDialog::MyDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::MyDialog)
{
    ui->setupUi(this);
    QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(this);
    connect(shortcut, SIGNAL(activated()), this, SLOT(toggleVisibility()));
    shortcut->setShortcut(QKeySequence("Ctrl+Shift+F12"));
}

MyDialog::~MyDialog()
{
    delete ui;
    delete mAnimation;
}

void MyDialog::toggleVisibility()
{
    mAnimation = new QPropertyAnimation(this, "geometry",this);
    mAnimation->setDuration(1000);
    mAnimation->setEasingCurve(QEasingCurve::InOutQuad);
    mAnimation->setEndValue(QRect(0, 2000, 1024, 300));
    mAnimation->start();
    //this->setFixedHeight(800);
}


void MyDialog::on_pushButton_clicked()
{
    mAnimation = new QPropertyAnimation(this, "geometry",this);
    mAnimation->setDuration(1000);
    mAnimation->setEasingCurve(QEasingCurve::InOutQuad);
    mAnimation->setEndValue(QRect(0, 2000, 1024, 300));
    mAnimation->start();
    //this->setFixedHeight(800);
}
